const  express=require("express");
const  app=express();

const querystring = require('querystring');

app.use((req,res,next)=>{
    let  str="";
    req.on("data",(data)=>{
        str+=data;
    });
    req.on("end",()=>{
        //console.log(str);
        console.log(querystring.parse(str));
        req.body=querystring.parse(str);
        next();
    })
});

app.get("/",(req,res)=>{
    res.sendFile("./views/index.html",{root:__dirname});
});
app.post("/query",(req,res)=>{
    res.send(req.body);
});

app.listen(1500,()=>{
     console.log('server running at http://127.0.0.1:1500') ;
});